package handler

import (
	"gin/global"
	course "gin/internal/pb/course"
	"github.com/gin-gonic/gin"
	"net/http"
	"strconv"
)

func CourseInfo(c *gin.Context) {
	info, err := global.CourseClient.CourseInfo(c, &course.CourseInfoRequest{})
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"mes": "错误"})
		return
	}
	c.JSON(http.StatusOK, gin.H{"code": 200, "data": info.Info})
}
func CourseDetail(c *gin.Context) {
	id, _ := strconv.Atoi(c.Param("id"))
	detail, err := global.CourseClient.CourseDetail(c, &course.CourseDetailRequest{Id: int32(id)})
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"mes": "错误"})
		return
	}
	c.JSON(http.StatusOK, gin.H{"code": 200, "data": detail})
}
